home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH2 / SRC / FILLMODE.FRM < prev    next >
Text File  |  1996-04-18  |  4KB  |  132 lines

  1. VERSION 4.00
  2. Begin VB.Form FillModeForm 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "Polygon Fill Mode"
  5.    ClientHeight    =   3780
  6.    ClientLeft      =   1545
  7.    ClientTop       =   1815
  8.    ClientWidth     =   6330
  9.    Height          =   4470
  10.    Left            =   1485
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   252
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   422
  15.    Top             =   1185
  16.    Width           =   6450
  17.    Begin VB.Menu mnuFile 
  18.       Caption         =   "&File"
  19.       Begin VB.Menu mnuFileExit 
  20.          Caption         =   "E&xit"
  21.       End
  22.    End
  23. End
  24. Attribute VB_Name = "FillModeForm"
  25. Attribute VB_Creatable = False
  26. Attribute VB_Exposed = False
  27. Option Explicit
  28.  
  29.  
  30. Private Sub Form_Load()
  31. Const XMOVE = 140
  32. Const YMOVE = 120
  33. Dim Points(0 To 10) As POINTAPI
  34. #If Win32 Then
  35.     Dim NumPoints(0 To 1) As Long
  36. #Else
  37.     Dim NumPoints(0 To 1) As Integer
  38. #End If
  39. Dim brush As Integer
  40. Dim old_brush As Integer
  41. Dim old_mode As Integer
  42. Dim i As Integer
  43.  
  44.     ' Counterclockwise star.
  45.     Points(0).x = 72:  Points(0).y = 0
  46.     Points(1).x = 8:   Points(1).y = 119
  47.     Points(2).x = 133: Points(2).y = 24
  48.     Points(3).x = 16:  Points(3).y = 37
  49.     Points(4).x = 120: Points(4).y = 108
  50.     Points(5).x = 72:  Points(5).y = 0
  51.     NumPoints(0) = 6
  52.     ' Counterclockwise rectangle.
  53.     Points(6).x = 43:  Points(6).y = 110
  54.     Points(7).x = 108: Points(7).y = 110
  55.     Points(8).x = 108: Points(8).y = 16
  56.     Points(9).x = 43:  Points(9).y = 16
  57.     Points(10).x = 43: Points(10).y = 110
  58.     NumPoints(1) = 5
  59.     
  60.     ' Fill with a red brush.
  61.     brush = CreateSolidBrush(vbRed)
  62.     old_brush = SelectObject(hdc, brush)
  63.  
  64.     ' Draw the star ALTERNATE.
  65.     old_mode = SetPolyFillMode(hdc, ALTERNATE)
  66.     If Polygon(hdc, Points(0), NumPoints(0)) = 0 Then Exit Sub
  67.     
  68.     ' Move down.
  69.     For i = LBound(Points) To UBound(Points)
  70.         Points(i).y = Points(i).y + YMOVE
  71.     Next i
  72.     
  73.     ' Draw the star WINDING.
  74.     old_mode = SetPolyFillMode(hdc, WINDING)
  75.     If Polygon(hdc, Points(0), NumPoints(0)) = 0 Then Exit Sub
  76.  
  77.     ' Move up and to the right.
  78.     For i = LBound(Points) To UBound(Points)
  79.         Points(i).x = Points(i).x + XMOVE
  80.         Points(i).y = Points(i).y - YMOVE
  81.     Next i
  82.     
  83.     ' Draw the star and box ALTERNATE.
  84.     old_mode = SetPolyFillMode(hdc, ALTERNATE)
  85.     If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
  86.     
  87.     ' Move down.
  88.     For i = LBound(Points) To UBound(Points)
  89.         Points(i).y = Points(i).y + YMOVE
  90.     Next i
  91.  
  92.     ' Draw the star and box WINDING.
  93.     old_mode = SetPolyFillMode(hdc, WINDING)
  94.     If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
  95.     
  96.     ' Move up and to the right.
  97.     For i = LBound(Points) To UBound(Points)
  98.         Points(i).x = Points(i).x + XMOVE
  99.         Points(i).y = Points(i).y - YMOVE
  100.     Next i
  101.  
  102.     ' Make the rectangle clockwise.
  103.     i = Points(7).x: Points(7).x = Points(9).x: Points(9).x = i
  104.     i = Points(7).y: Points(7).y = Points(9).y: Points(9).y = i
  105.     
  106.     ' Draw the star and box ALTERNATE.
  107.     old_mode = SetPolyFillMode(hdc, ALTERNATE)
  108.     If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
  109.     
  110.     ' Move down.
  111.     For i = LBound(Points) To UBound(Points)
  112.         Points(i).y = Points(i).y + YMOVE
  113.     Next i
  114.  
  115.     ' Draw the star and box WINDING.
  116.     old_mode = SetPolyFillMode(hdc, WINDING)
  117.     If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
  118.     
  119.     ' Delete the brush.
  120.     brush = SelectObject(hdc, old_brush)
  121.     If DeleteObject(brush) = 0 Then Exit Sub
  122. End Sub
  123.  
  124.  
  125.  
  126.  
  127. Private Sub mnuFileExit_Click()
  128.     Unload Me
  129. End Sub
  130.  
  131.  
  132.